﻿using System;

namespace Batman.Cache.Providers
{
    public interface ICachingProvider
    {
        object Get(string cacheKey);

        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="factory">如果缓存为null，则执行该委托方法，并把结果写入缓存</param>
        /// <param name="absoluteExpirationRelativeToNow">默认是30秒缓存</param>
        /// <returns></returns>
        object Get(string cacheKey, Func<object> factory, TimeSpan? absoluteExpirationRelativeToNow = null);


        void Set(string cacheKey, object cacheValue, TimeSpan absoluteExpirationRelativeToNow);

        /// <summary>
        /// 移除指定缓存
        /// </summary>
        /// <param name="cacheKey"></param>
        void Remove(string cacheKey);
    }
}
